/*
 * @Description: 封装sessionStorage配置文件
 * @Author: ligy
 * @Date: 2022-03-21 00:12:26
 * @LastEditTime: 2022-03-21 00:13:46
 */
// 存储数据
export const setSessionItem = (key, value) =>{
  // 将数组或对象类型的数据转换为字符串进行存储
  if(typeof value === 'object'){
    value = JSON.stringify(value)
  }
  window.sessionStorage.setItem(key, value)
}

// 获取数据
export const getSessionItem = key =>{
  const data = window.sessionStorage.getItem(key)
  try {
    return JSON.parse(data)
  } catch (err) {
    return data
  }
}
// 删除数据
export const removeSessionItem = key =>{
  window.sessionStorage.removeItem(key)
}
